#include<stdio.h>
int main()
{
	int n;
	while (~scanf("%d", &n)) {
		if (n == 0) {
			break;
		}
		if (n == 1) {
			printf("%3d\n", 1);
		}
		int k = 1;
		while (k < 4 * n - 4) {
			for (int i = 0; i < n; i++) {
				printf("%3d", k++);
			}
			printf("%\n");
			
		}
	}
	return 0;
}